package com.cleaningcloud.cld.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.cleaningcloud.common.log.annotation.Log;
import com.cleaningcloud.common.log.enums.BusinessType;
import com.cleaningcloud.common.security.annotation.RequiresPermissions;
import com.cleaningcloud.cld.domain.CldProjectPostWages;
import com.cleaningcloud.cld.service.ICldProjectPostWagesService;
import com.cleaningcloud.common.core.web.controller.BaseController;
import com.cleaningcloud.common.core.web.domain.AjaxResult;
import com.cleaningcloud.common.core.utils.poi.ExcelUtil;
import com.cleaningcloud.common.core.web.page.TableDataInfo;

/**
 * 项目岗位工资配置Controller
 * 
 * @author cleaningcloud
 * @date 2024-10-15
 */
@RestController
@RequestMapping("/wages")
public class CldProjectPostWagesController extends BaseController
{
    @Autowired
    private ICldProjectPostWagesService cldProjectPostWagesService;

    /**
     * 查询项目岗位工资配置列表
     */
//    @RequiresPermissions("cld:wages:list")
    @GetMapping("/list")
    public TableDataInfo list(CldProjectPostWages cldProjectPostWages)
    {
        startPage();
        List<CldProjectPostWages> list = cldProjectPostWagesService.selectCldProjectPostWagesList(cldProjectPostWages);
        return getDataTable(list);
    }

    /**
     * 导出项目岗位工资配置列表
     */
//    @RequiresPermissions("cld:wages:export")
    @Log(title = "项目岗位工资配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CldProjectPostWages cldProjectPostWages)
    {
        List<CldProjectPostWages> list = cldProjectPostWagesService.selectCldProjectPostWagesList(cldProjectPostWages);
        ExcelUtil<CldProjectPostWages> util = new ExcelUtil<CldProjectPostWages>(CldProjectPostWages.class);
        util.exportExcel(response, list, "项目岗位工资配置数据");
    }

    /**
     * 获取项目岗位工资配置详细信息
     */
//    @RequiresPermissions("cld:wages:query")
    @GetMapping(value = "/{projectPostWagesId}")
    public AjaxResult getInfo(@PathVariable("projectPostWagesId") Long projectPostWagesId)
    {
        return success(cldProjectPostWagesService.selectCldProjectPostWagesByProjectPostWagesId(projectPostWagesId));
    }

    /**
     * 新增项目岗位工资配置
     */
//    @RequiresPermissions("cld:wages:add")
    @Log(title = "项目岗位工资配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CldProjectPostWages cldProjectPostWages)
    {
        return toAjax(cldProjectPostWagesService.insertCldProjectPostWages(cldProjectPostWages));
    }

    /**
     * 修改项目岗位工资配置
     */
//    @RequiresPermissions("cld:wages:edit")
    @Log(title = "项目岗位工资配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CldProjectPostWages cldProjectPostWages)
    {
        return toAjax(cldProjectPostWagesService.updateCldProjectPostWages(cldProjectPostWages));
    }

    /**
     * 删除项目岗位工资配置
     */
//    @RequiresPermissions("cld:wages:remove")
    @Log(title = "项目岗位工资配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectPostWagesIds}")
    public AjaxResult remove(@PathVariable Long[] projectPostWagesIds)
    {
        return toAjax(cldProjectPostWagesService.deleteCldProjectPostWagesByProjectPostWagesIds(projectPostWagesIds));
    }
}
